package com.pt25.service.sys.interfaces.vo.config;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.pt25.base.util.JsonUtil;
import com.pt25.base.util.PageUtil;
import com.pt25.base.validator.CreateGroup;
import com.pt25.base.validator.UpdateGroup;
import com.pt25.service.sys.domain.config.ddo.ConfigData;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.*;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(
        callSuper = true
)
public class ConfigDataVo extends PageUtil.PageBase {
    @JsonFormat(
            shape = JsonFormat.Shape.STRING
    )

    @NotNull(groups = {UpdateGroup.class}, message = "id不能为空")
    private Long id;

    @JsonFormat(shape = JsonFormat.Shape.STRING)
    @NotNull(groups = {CreateGroup.class}, message = "configTypeId不能为空")
    private Long configTypeId;

    @NotEmpty(groups = {CreateGroup.class}, message = "dataType不能为空")
    private String dataType;

    @NotEmpty(groups = {CreateGroup.class}, message = "dataKey不能为空")
    private String dataKey;

    @NotEmpty(groups = {CreateGroup.class}, message = "dataName不能为空")
    private String dataName;

    @NotEmpty(groups = {CreateGroup.class}, message = "dataDescription不能为空")
    private String dataDescription;

    @NotEmpty(groups = {CreateGroup.class}, message = "valueType不能为空")
    private String valueType;


    public ConfigData toConfigData() {
        return JsonUtil.toBean(JsonUtil.toJson(this), ConfigData.class);
    }


}
